package com.website.web.front.controller;

import com.website.common.core.controller.BaseController;
import com.website.common.core.page.PageDomain;
import com.website.common.core.page.TableSupport;
import com.website.custom.domain.WCase;
import com.website.custom.service.IWCaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class CaseController extends BaseController {

    @Autowired
    private IWCaseService wCaseService;

    @GetMapping("/case")
    public String about(HttpServletRequest request, HttpServletResponse response, ModelMap model) {

        // 获取案例列表
        startPage();
        List<WCase> wCases = wCaseService.selectWCaseList(null);
        int pageCount = wCaseService.caseCount();
        model.addAttribute("wCases", wCases);
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        model.addAttribute("current", pageNum);
        model.addAttribute("caseCount", pageCount);
        return "front/case";
    }
}
